package com.johnboy.group.salary.service.Impl;

import java.io.Serializable;
import java.util.List;

import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.johnboy.group.salary.dao.BaseDao;
import com.johnboy.group.salary.service.BaseService;

public abstract class BaseServiceImpl<T> implements BaseService<T> {

	public abstract BaseDao<T> entityDAO();

	@Override
	@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { Throwable.class })
	public int deleteById(Serializable id) throws Exception {
		return entityDAO().deleteById(id);
	}

	@Override
	@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { Throwable.class })
	public int insert(T o) throws Exception {
		return entityDAO().insert(o);
	}

	@Override
	@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { Throwable.class })
	public int update(T o) throws Exception {
		return entityDAO().update(o);
	}

	@Override
	@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { Throwable.class })
	public T getOneById(Serializable id) throws Exception {
		return entityDAO().getOneById(id);
	}

	@Override
	@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { Throwable.class })
	public int insertBatch(List<T> lists) throws Exception {
		return entityDAO().insertBatch(lists);
	}

}
